%% Analysis of Steady-State 25C vs. 37C BarSeq data from Feb. 18 2021 samples
load('EcoliBW25113_Tn_LB_steadystate_20200218.mat');
temp = Steadystates_Feb18;
close all;

%% Create plotting arrays
time_25C = [-15 0 10 20 30 40 60 90];
fitness_array_25C = [temp.setAIT002218_25to25_15min_B temp.setAIT003218_25to25_0min_B temp.setAIT004218_25to25_10min_B temp.setAIT005218_25to25_20min_B temp.setAIT006218_25to25_30min_B temp.setAIT007218_25to25_40min_B temp.setAIT008218_25to25_60min_B temp.setAIT009218_25to25_90min_B];

time_37C = [-10 10 20 30 40 60 90];
fitness_array_37C = [temp.setAIT019218_37to37_10min_B temp.setAIT021218_37to37_10min_B temp.setAIT022218_37to37_20min_B temp.setAIT023218_37to37_30min_B temp.setAIT024218_37to37_40min_B temp.setAIT025218_37to37_60min_B temp.setAIT026218_37to37_90min_B];

%% Plot 25C data
hits_25C = [];

figure;
for k=1:size(fitness_array_25C,1)
    if mean(abs(fitness_array_25C(k,:)))<1.5
        plot(time_25C, fitness_array_25C(k,:), 'color', [0 0 0]+0.8);
    else
        plot(time_25C, fitness_array_25C(k,:), 'b');
        hits_25C = [hits_25C; k];
        text(time_25C(end), fitness_array_25C(k,end), temp.genename(k));
    end
    hold on;
end
ylim([-6 2]);
set(gcf, 'Position', [0 0 400 300]);
set(gca,'fontsize', 20);
box off;
xlabel('Time (min)');
ylabel('Log2 fitness');

%% Plot 37C data
hits_37C = [];

figure;
for k=1:size(fitness_array_37C,1)
    if mean(abs(fitness_array_37C(k,:)))<1.5
        plot(time_37C, fitness_array_37C(k,:), 'color', [0 0 0]+0.8);
    else
        plot(time_37C, fitness_array_37C(k,:), 'r');
        hits_37C = [hits_37C; k];
        text(time_37C(end), fitness_array_37C(k,end), temp.genename(k));
    end
    hold on;
end
ylim([-6 2]);
set(gcf, 'Position', [0 0 400 300]);
set(gca,'fontsize', 20);
box off;
xlabel('Time (min)');
ylabel('Log2 fitness');

%% Display hits
disp('25 to 25 hits');
temp.genename(hits_25C)
disp('37 to 37 hits');
temp.genename(hits_37C)

